<!DOCTYPE html>
<html lang="en">
<head>
    <title>H5请假</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <link rel="stylesheet" href="/dist/plugins/calendar/calendar.css"/>
</head>
<style>
    [v-cloak] {
        display: none;
    }

    * {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        font-size: 12px;
    }

    body {
        margin: 0px;
        background: #eee;
    }

    table {
        border-spacing: 0;
        border-collapse: collapse;
        display: table;
    }

    .weather {
        text-align: center;
        font-size: 16px;
        position: absolute;
        top: 5px;
        line-height: 24px;
        float: left;
    }

    th {
        font-weight: bold;
    }

    table.text-center, table.text-center td, table.text-center th {
        text-align: center;
        font-size: 12px;
    }

    .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
        border: 1px solid #cbcbcd;
        height: 24px;
        position: relative;
        color: #333;
        padding: 0 4px;
    }

    .tryStyle {
        width: 34px;
        height: 17px;
        line-height: 17px;
        font-size: 12px;
        top: -3px;
        right: -29px;
        position: absolute;
        border-radius: 50px;
        margin-top: 4px;
        background: #ff131c;
        color: #fff;
        margin-right: -2px;
        transform: scale(0.7);
        text-align: center;
    }

    table th {
        background: #f8f8f8;
    }

    .table-bordered {
        border: 1px solid #cbcbcd;
    }

    .table {
        width: 100%;
        max-width: 100%;
    }

    .hidden {
        display: none;
    }

    .lineOne, .lineTwo {
        text-align: left;
    }

    .tdColor {
        background-color: #f8f8f8;
        font-weight: bold;
    }

    .lineOne span {
        max-height: 24px;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        text-align: left;
    }

    .lineTwo span {
        max-height: 48px;
        line-height: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        text-align: left;

    }

    .div-td-content-more {
        position: absolute;
        height: auto;
        z-index: 999;
        line-height: 20px;
        background-color: #d3e8fd;
        padding: 8px 6px;
        border: 1px solid #e8e8ea;
        display: none;
    }

    .div-td-content-more i {
        width: 15px;
        height: 12px;
        background: url("/dist/img/more-icon.png");
        position: absolute;
        left: 50px;
        top: -12px;
    }

    .clear {
        clear: both
    }

    .boxItem {
        width: 100%;
        padding: 10px;
        padding-top: 5px;
        padding-bottom: 0;
        background: inherit;
        background-color: rgba(255, 255, 255, 1);
        border: none;
        position: relative;
    }

    .boxItemTitle {
        color: #000;
        font-size: 16px;
        font-weight: bold;
        margin-bottom: 6px;
        text-align: right;
    }

    .home {
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 10px;
        height: 14px;
        line-height: 14px;
        text-align: center;
    }

    .dian-icon {
        background: url("/dist/img/dian.png") no-repeat;
        background-size: cover;
        width: 14px;
        height: 14px;
        display: inline-block;
    }

    .jiaobiao, .jiaobiaoNew {
        position: relative;
    }

    .jiaobiao i {
        display: block;
        width: 0;
        height: 0;
        border-width: 0px 0 12px 12px;
        border-style: solid;
        border-color: transparent transparent transparent #2a8cec;
        position: absolute;
        top: 0px;
        left: 0px;
    }

    .jiaobiaoNew i {
        display: block;
        width: 12px;
        height: 12px;
        background: url("/dist/img/newLog2.png");
        background-size: 100% 100%;
        position: absolute;
        top: 0px;
        left: 0px;
    }

    .lineImg {
        padding-top: 5px !important;
        padding-bottom: 10px !important;
    }

    .lineImg img {
        height: 45px;
        width: 45px;
        float: left;
        margin: 10px;
    }

    .newCustomer {
        background: url(/dist/img/new.png) no-repeat;
        background-size: cover;
        width: 20px;
        height: 20px;
        right: 0;
        top: 2px;
        position: absolute;
    }

    .wajueji {
        padding-left: 140px;
        background: url("/dist/img/wajueji.png") no-repeat;
        background-size: 120px 88px;
        height: 88px;
        line-height: 88px;
        color: red;
        font-size: 14px;
        font-weight: bold;
        margin-left: 50px;
    }

    .qipao {
        /*background: url(/dist/img/qipao.png);*/
        background-size: 100% 100%;
        height: 88px;
        /* padding: 0 20px; */
        padding-left: 20px;
        /*padding-right: 20px;*/
        color: red;
        line-height: 88px;
        float: left;
        font-size: 14px;
        font-weight: bold;
    }

    .plan1 {
        background: url("/dist/img/plan1.png") no-repeat center center;
        background-size: 100%;
    }

    .plan2 {
        background: url("/dist/img/plan2.png") no-repeat center center;
        background-size: 100%;
    }

    .plan3 {
        background: url("/dist/img/plan3.png") no-repeat center center;
        background-size: 100%;
    }

    .boxItemTitleNotice {
        color: red;
        font-size: 22px;
        font-weight: bold;
        margin-bottom: 10px;
        text-align: center;
    }

    .boxItemTitleNotice i {
        background: url("/dist/img/jg.png") no-repeat center center;
        height: 22px;
        width: 22px;
        background-size: cover;
        display: inline-block;
        margin-bottom: -3px;
        margin-left: 5px;
    }

    .boxItemTitleNoticeTime {
        color: red;
        font-size: 20px;
        font-weight: bold;
        margin-bottom: 10px;
        text-align: center;
    }

    .boxItemTitleNoticeTime i {
        background: url("/dist/img/jg.png") no-repeat center center;
        height: 16px;
        width: 16px;
        background-size: cover;
        display: inline-block;
        margin-bottom: -3px;
        margin-left: 5px;
    }

    .search-button {
        width: 14px;
        height: 14px;
        background-image: url(/dist/img/glass.jpg);
        border: 0 none;
        cursor: pointer;
        margin-top: 0px;
    }

    input[type=button] {
        outline: none;
    }

    .oaBtn {
        background: url(/dist/img/btn-bj2.png) repeat-y !important;
        background-size: 100% 100% !important;
        color: #fff !important;
    }

    .btn-group-sm > .btn, .btn-sm {
        padding: 2px 10px;
    }

    .btn {
        border-radius: 3px;
        -webkit-box-shadow: none;
        box-shadow: none;
        border: 1px solid transparent;
    }

    .pull-right {
        float: right !important;
    }

    .blue {
        color: #39c;
    }

    .red {
        color: #e03800;
    }

    .weather img {
        height: 26px;
        width: 26px;
        float: left;
    }

    .info p {
        margin: auto;
    }


    .demo-box{
        border:none;
        margin-bottom: 20px;
    }
    .qingjia {
        background: url("/dist/img/icon_seal_qingjia.png") no-repeat bottom right;
        background-size: 30%;
    }

    .ht-rili-leftarr {
        display: none;
    }

    .ht-rili-rightarr {
        display: block;
    }
    .qjsy{
        border-top:1px solid #ddd;
        background: #fff;
    }
    .qjsy textarea,.desc{
        width: 100%;
        border: none;
        font-size: 16px;
        padding: 0 20px;
        line-height: 24px;
        height: 80px;
    }
    .qjsm{
        height: 45px;
        line-height: 45px;
        padding-left: 20px;
        font-size: 16px;
        color: #83888a;
    }
    .qjsmActive{
        height: 45px;
        line-height: 45px;
        padding-left: 20px;
        font-size: 16px;
        color: #4796e5;
    }
    .qjsy .title{
        height: 45px;
        line-height: 45px;
        padding-left: 20px;
        font-size: 16px;
        color: #262626;
        position: relative;
    }
    .qjsy .title i{
        position: absolute;
        left: 5px;
        top: 1px;
        font-size: 20px;
        color: red;
    }
    .qjsm span{
        font-size: 16px;
        margin: 0 2px;
    }
    .tijiaoBtn{
        position: fixed;
        bottom:0;
        left:0;
        width: 100%;
        height: 50px;
        line-height: 50px;
        background: #2a8cec;
        color:#fff;
        text-align: center;
        font-weight: bold;
        font-size: 16px;
    }
    .ht-rili-td:nth-child(7n+1) .ht-rili-day, .ht-rili-td:nth-child(7n) .ht-rili-day{
        color:#333;
    }
    .shangYue .ht-rili-day, .xiaYue .ht-rili-day {
        color: #83888a  !important;
    }
    .leaveActive .ht-rili-money, .leaveActive .ht-rili-day {
        color: #fff !important;
    }

    .table-detail {
        width: 100%;
        border-left: 1px solid #e8e8e9;
        border-top: 1px solid #e8e8e9;
        border-spacing: 0;
        /*table-layout: fixed;*/
        /*background-color: #f5f5f5;*/
        /*background: #d3e8fd !important;*/
        color: black !important;
    }
    .table-detail .td-title {
        background-color: #f5f5f5;
        height: 30px;
    }




    table th {

        background: #d3e8fd;
        color: black ;
        font-size: 12px ;
        text-align: center;
        margin-top: -1px;
        height: 30px;

    }

    .table-detail td {
        border-right: 1px solid #e8e8e9;
        border-bottom: 1px solid #e8e8e9;
        padding-left: 0px !important;
        padding-right: 0px !important;
        padding-top: 0px !important;
        padding-bottom: 0px !important;
        height: 45px;
        /*line-height: 29px;*/
        text-align: center;
        position: relative;
        overflow: hidden;
        word-wrap: break-word;
        background: #fff;
    }

    .oaColor {
        color: #2a8cec;
    }
    .oa-name{
        width: 36px;
        font-size: 12px;
        text-align: justify;
        display: block;
        margin: 0 auto;
        line-height: 24px;
        height: 24px;
        overflow: hidden;
        white-space: normal;
    }
    .oa-name:after {
        content: " ";
        display: inline-block;
        width: 100%;
    }
</style>
<body>
<section class="content" id="app" v-cloak style="padding-bottom: 50px;">
    <div class="div-td-content-more"><i></i></div>
    <!--今日已请假-->
    <template v-if="isLeave">
        <div class="qjsmActive">{{leaveTitle}}</div>
        <div class="qjsy">
            <div class="title"><i>*</i>请假事由</div>
            <div class="desc">{{leaveDesc}}</div>
        </div>
        <div class="tijiaoBtn" @click="xiaojia">销假</div>
    </template>
    <template v-else>
        <div class="qjsm" v-if="num==0">请选择请假日期，共计请假<span :style="num?'color:red;':''">{{num}}</span>天</div>
        <div class="qjsm" v-else-if="num==1"><span style="color:rgb(42, 140, 236)">{{formatYR(beginTime)}}</span> 请假<span :style="num?'color:red;':''">{{num}}</span>天</div>
        <div class="qjsm" v-else><span  style="color:rgb(42, 140, 236)">{{formatYR(beginTime)}}</span> 至 <span  style="color:rgb(42, 140, 236)">{{formatYR(endTime)}}</span> 请假<span :style="num?'color:red;':''">{{num}}</span>天</div>
        <div class="templateStyle">
            <div class="calendar-box demo-box" id="demo-box"></div>
        </div>
        <div class="qjsy">
            <div class="title"><i>*</i>请假事由</div>
            <textarea name="" id="" cols="30" rows="10" placeholder="请输入..." v-model="leaveDesc"></textarea>
        </div>

        <table class="table table-hover text-center  shTable" v-if="createAudit&&createAudit.length>0" style="        margin-top: 20px;">
            <thead>
            <tr>
                <th colspan="4">审批进度</th>
            </tr>
            </thead>
        </table>

        <table class="table-detail" style="width: 100%;table-layout: fixed;" v-if="createAudit&&createAudit.length>0">
            <tbody>
            <tr>
                <td class="td-title" style="width: 50px;text-align: center;">审核人</td>
                <td class="td-title" style="width: 60px;text-align: center;">审核状态</td>
                <td class="td-title" style="width: 100px;text-align: center;">审核时间</td>
                <td class="td-title">审核意见</td>
            </tr>
            <tr v-for="(item,i) in createAudit">

                <td style="text-align: center;">
                    <span class="oa-name oaColor">{{item.auditorName}}</span>
                </td>
                <td style="text-align: center;">
                    <span v-if="item.auditFlag===0" style="color:red;">待审核</span>
                    <span v-else-if="item.auditFlag===1" class="oaColor">已通过</span>
                    <span v-else-if="item.auditFlag===2" class="oaColor">已驳回</span>
                    <span v-else-if="item.auditFlag===-1" class="oaColor">未提交</span>
                    <span v-else-if="!item.auditFlag" class="oaColor">未提交</span>
                </td>
                <td style="text-align: center;" class="oaColor">
                    {{formatDate(item.auditTime)}}
                </td>
                <td style="text-align: left;">
                    <span style="padding-left: 10px;" class="moreSpan oaColor">{{item.auditAdvise}}</span>
                </td>
            </tr>


            </tbody>
        </table>

        <div class="tijiaoBtn" @click="save">提交申请</div>
    </template>

</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>

<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/calendar/calendar-pro.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });
</script>
<script type="text/javascript">

    var app = new Vue({
        el: "#app",
        data: {
            userId: getUrlParamObj().userId,
            dateTime: getUrlParamObj().dateTime,
            leaveDesc:"",
            leaveTitle:'',
            num:0,
            beginTime:"",
            endTime:"",
            isLeave: false,
            go:true,
            createAudit:[]

        },
        methods: {
            formatYR: function (now) {
                if (now) {
                    return new Date(now).Format(TimeFormat.pcListYR)
                }
            },
            formatDate: function (now) {
                if (now) {
                    return new Date(now).Format(TimeFormat.middle)
                }
            },
            getAuditList:function () {
                var that=this;
                $.wyui.postMethod('/signIn/getAuditList.json', {
                    "userId": that.userId
                }, function (data) {
                   that.createAudit=data.createAuditors;
                });
            },
            xiaojia:function () {
                var that=this;

                JSBridge.call(UI, 'showLoading', {})
                $.wyui.postMethod('/signIn/delLeaveByDay.json', {
                    "userId": that.userId,
                    "leaveDate": new Date().Format("yyyy-MM-dd")
                }, function (data) {
                    JSBridge.call(UI, 'hideLoading')
                    JSBridge.call(UI, 'showToast', {title: "销假成功"})
                    window.location.reload()
                });
            },
            save:function () {
                var that=this;
                JSBridge.call(UI, 'showLoading', {})
                if(that.endTime){
                    that.endTime=new Date(that.endTime).Format("yyyy-MM-dd")
                }else{
                    that.endTime=that.beginTime
                }
                console.log(that.beginTime,that.endTime)
                if(!that.num){
                    JSBridge.call(UI, 'showToast', {title: "请至少选择一天"})
                    return false;
                }
                if(that.leaveDesc==""){
                    JSBridge.call(UI, 'showToast', {title: "请填写请假原因"})
                    return false;
                }
                if(that.go){
                    that.go=false
                    $.wyui.postMethod('/signIn/saveLeave.json', {
                        "userId": that.userId,
                        "remark": that.leaveDesc,
                        "beginTime":that.beginTime,
                        "endTime":that.endTime,
                        "auditFlag":-1,
                        "createAuditors":that.createAudit
                    }, function (data) {
                        JSBridge.call(UI, 'showToast', {title: "提交申请成功"})
                        var param = {
                            backRefresh: true,       //是否返回刷新
                        }
                        JSBridge.call(ROUTER, 'navigateBack', param)

                    });
                }

            },
            //打开基本信息
            lookInfo: function (userId) {
                var that = this
                var obj = {
                    type: 'customerList',
                    url: '/reportForm/personnel/entry.html?userId=' + userId,
                    name: '基本信息'
                }
                prompt(JSON.stringify(obj));
            },
            getLeaveByDay: function () {
                //获取当天请假信息
                var that = this;
                that.go=true;
                JSBridge.call(UI, 'showLoading', {})
                $.wyui.postMethod('/signIn/getLeaveByDay.json', {
                    "userId": that.userId,
                    "leaveDate": that.dateTime
                }, function (data) {
                    console.log(data)
                    JSBridge.call(UI, 'hideLoading')
                    if(data){
                        if(data.beginTime==data.endTime){
                            var date=new Date(data.leaveDate).Format("M")+"月"+new Date(data.leaveDate).Format("dd")+"日";
                            that.leaveTitle=date+" 已请假"
                        }else{
                            that.leaveTitle=new Date(data.beginTime).Format("M")+"月"+new Date(data.beginTime).Format("dd")+"日"+" 至 "+new Date(data.endTime).Format("M")+"月"+new Date(data.endTime).Format("dd")+"日"+" 已请假"
                        }
                        that.leaveDesc=data.remark
                        that.isLeave=true
                    }else{
                        that.isLeave=false
                        var id = "#demo-box";
                        var res = {"current": [], "last": [], "next": []}
                        console.log(res)
                        $(id).calendar({
                            ele: id, //依附
                            title: '',
                            data: res,
                            type: 'leave',
                            bgTime:"",
                            edTime:""
                        });
                    }

                });
            },
            get_date: function (list) {
                var data;
                var current = [];
                var last = [];
                var next = [];
                var benNian = new Date().Format("yyyy");
                var benYue = new Date().Format("M");
                var lastTime = '';
                var currentTime = new Date().Format("yyyy-MM");
                var today = new Date().Format("yyyy-MM-dd");
                var nextTime = '';
                if (Number(benYue) + 1 > 12) {
                    nextTime = Number(benNian) + 1 + "-01"
                } else if (Number(benYue) + 1 < 10) {
                    nextTime = Number(benNian) + "-0" + (Number(benYue) + 1)
                } else {
                    nextTime = Number(benNian) + "-" + (Number(benYue) + 1)
                }
                if (Number(benYue) - 1 < 1) {
                    lastTime = Number(benNian) - 1 + "-12"
                } else if (Number(benYue) - 1 < 10) {
                    lastTime = Number(benNian) + "-0" + (Number(benYue) - 1)
                } else {
                    lastTime = Number(benNian) + "-" + (Number(benYue) - 1)
                }
                for (var i = 0; i < list.length; i++) {
                    if (lastTime == list[i].leaveDate.substring(0, 7)) {
                        last.push({date: list[i].leaveDate, data: '假', yy: list[i].remark})
                    }
                    if (currentTime == list[i].leaveDate.substring(0, 7)) {
                        if (today == list[i].leaveDate) {
                            current.push({date: list[i].leaveDate, data: '假', today: true, yy: list[i].remark})
                        } else {
                            current.push({date: list[i].leaveDate, data: '假', yy: list[i].remark})
                        }
                    }
                    if (nextTime == list[i].leaveDate.substring(0, 7)) {
                        next.push({date: list[i].leaveDate, data: '假', yy: list[i].remark})
                    }
                }
                data = {
                    last: last,
                    current: current,
                    next: next
                }
                console.log(data)
                return data

            },
            getCountDays: function (dateStr) {//返回当月的天数
                var curDate = new Date(dateStr);
                var curMonth = curDate.getMonth();
                curDate.setMonth(curMonth + 1);
                curDate.setDate(0);
                return curDate.getDate();
            },

        },
        mounted: function () {
            var that = this;
            that.getLeaveByDay();
            that.getAuditList();

        }
    })
    //    Vue.directive('line-inserted2', {
    //        inserted: function (el, binding) {
    //            console.log("11")
    //            showCalendar();
    //        }
    //    });
</script>
<script>




</script>
</body>
</html>